keyfile_set_from_vardict: free the string array
authorSimon McVittie <smcv@debian.org>
Sat, 29 Oct 2016 17:36:19 +0000 (18:36 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sun, 30 Oct 2016 22:11:15 +0000 (22:11 +0000)
g_variant_get_strv is (transfer container): the caller is expected to
free the array, but not the individual strings.

Leak found with valgrind memcheck.

Signed-off-by: Simon McVittie <smcv@debian.org>
Closes: #556
Approved by: cgwalters

src/libostree/ostree-repo.c

index c897f819a6d96173cabd699ec3a6c71205f6978a..2e35faf836d9c1c65f99f40f6bef3397e8d9eba8 100644 (file)
@@ -936,7 +936,7 @@ keyfile_set_from_vardict (GKeyFile     *keyfile,
       else if (g_variant_is_of_type (child, G_VARIANT_TYPE_STRING_ARRAY))
         {
           gsize len;
-          const char *const*strv_child = g_variant_get_strv (child, &len);
+          g_autofree const gchar **strv_child = g_variant_get_strv (child, &len);
           g_key_file_set_string_list (keyfile, section, key, strv_child, len);
         }
       else